
extract_source_list(packet_source)

add_library(
  Packet++
  $<TARGET_OBJECTS:hash-library>
  ${packet_source}
  # Force hash-library pcapng to be link fully static
)

extract_header_list(public_headers)
# Don't use set_target_properties CMake limit to 50 elements
set_property(TARGET Packet++ PROPERTY PUBLIC_HEADER ${public_headers})

target_include_directories(
  Packet++
  PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/header> $<INSTALL_INTERFACE:include/pcapplusplus>
  # Don't link with hash-library nor EndianPortable as they won't be exported
  PRIVATE $<TARGET_PROPERTY:hash-library,INCLUDE_DIRECTORIES>
  PRIVATE $<TARGET_PROPERTY:EndianPortable,INTERFACE_INCLUDE_DIRECTORIES>)

target_link_libraries(Packet++ PUBLIC Common++)

if(PCAPPP_INSTALL)
  install(
    TARGETS Packet++
    EXPORT PcapPlusPlusTargets
    ARCHIVE DESTINATION ${PCAPPP_INSTALL_LIBDIR}
    LIBRARY DESTINATION ${PCAPPP_INSTALL_LIBDIR}
    PUBLIC_HEADER DESTINATION ${PCAPPP_INSTALL_INCLUDEDIR}
    RUNTIME DESTINATION ${PCAPPP_INSTALL_BINDIR})
endif()

set_property(TARGET Packet++ PROPERTY OUTPUT_NAME "Packet++")
set_property(TARGET Packet++ PROPERTY VERSION ${PCAPPP_VERSION})
set_property(TARGET Packet++ PROPERTY COMPILE_WARNING_AS_ERROR ON)
